<?php
//update lại tổng at,pt cho toàn bộ khách hàng
include_once '../include/common.php';
$core = new core();

$list_customer_order = $core->db->get_results("SELECT * FROM zen_customer_order");
if($list_customer_order){

    foreach($list_customer_order as $order){

        $data_total_order = $core->db->get_row("SELECT SUM(product_num*store_price) as total_pt,SUM(product_num*stamp_price) as total_at
                                        FROM zen_customer_order_detail
                                        WHERE order_status !=6 AND customer_order_id=".$order->customer_order_id);
        var_dump($order->customer_order_id);
        echo "<pre>";var_dump($data_total_order);
        if($data_total_order->total_pt==null){
            $data_total_order->total_pt=0;
        }

        if($data_total_order->total_at==null){
            $data_total_order->total_at=0;
        }



        //sync data

        $core->db->query("UPDATE zen_customer_order SET
            total_store_price= $data_total_order->total_pt, total_stamp_price= $data_total_order->total_at
                WHERE customer_order_id=$order->customer_order_id");


    }

}
echo "DONE";
?>